# -*- coding: utf-8 -*-

# 绘制圆-困难

import sys, pygame, random, time, math
from pygame.locals import *

reload(sys)
sys.setdefaultencoding('utf-8')


pygame.init()
screen = pygame.display.set_mode((600, 500))
pygame.display.set_caption("圆")

pos_x = 300
pos_y = 250
radius = 200
angle = 360
num = 0
rect = pos_x-radius,pos_y-radius,radius*2,radius*2

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            sys.exit()

    keys = pygame.key.get_pressed()
    if keys[K_ESCAPE]:
        sys.exit()

    screen.fill((0, 0, 100))

    angle += 1
    if angle >= 360:
        angle = 0
        r = random.randint(0, 255)
        g = random.randint(0, 255)
        b = random.randint(0, 255)
        color = r,g,b

    x = math.cos(math.radians(angle)) * radius
    y = math.sin(math.radians(angle)) * radius

    pos = (int(pos_x+x), int(pos_y+y))
    pygame.draw.arc(screen, color, rect, 0, math.radians(angle), 10)

    pygame.display.update()

    time.sleep(0.016)

